package com.example.shop.controller;

import com.example.shop.entity.Orders;
import com.example.shop.entity.Organization;
import com.example.shop.service.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName OrganizationController
 * @Description TODO
 * @Author 萍
 * @Date 2025/3/26 10:22
 */
@RestController
@RequestMapping("/organization")
public class OrganizationController {

    @Autowired
    private OrganizationService organizationService;

    /**
     * 通过ID查询单条数据
     *
     * @param organizationid 主键
     * @return 实例对象
     */
    @GetMapping("/{organizationid}")
    public Organization queryById(@PathVariable Integer organizationid) {
        return organizationService.queryById(organizationid);
    }

    /**
     * 新增数据
     *
     * @param organization 实例对象
     * @return 实例对象
     */
    @PostMapping("/")
    public Organization insert(@RequestBody Organization organization) {
        return organizationService.insert(organization);
    }

    /**
     * 修改数据
     *
     * @param organization 实例对象
     * @return 实例对象
     */
    @PutMapping("/")
    public Organization update(@RequestBody Organization organization) {
        return organizationService.update(organization);
    }

    /**
     * 通过主键删除数据
     *
     * @param organizationid 主键
     * @return 是否成功
     */
    @DeleteMapping("/{organizationid}")
    public boolean deleteById(@PathVariable Integer organizationid) {
        return organizationService.deleteById(organizationid);
    }

    @GetMapping("/all")
    public List<Organization> queryAll() {
        List<Organization> organizationList = organizationService.queryAll();
        return organizationList;
    }
    //TODO 选择确定返回值
}
